package com.gpframework.module.ctn.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.ctn.domain.GpCtnOrder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName GpCtnOrderReq
 * @Author gpframework
 * @Date 2024-01-08
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpCtnOrderReq extends BaseReq {
    private static final long serialVersionUID = 1L;

     @ApiModelProperty("${column.columnComment}")
     private Long id;
     @ApiModelProperty("货柜安排表ID")
     private Long ctnArabgeId;
     @ApiModelProperty("订单ID")
     private Long receiptId;
    @ApiModelProperty("国内合作货代理管理ID")
    private Long domesticFreightForwardingId;
     @ApiModelProperty("清关公司ID")
     private Long agentCompanyId;
     @ApiModelProperty("品牌id")
     private Long brandId;
     @ApiModelProperty("店铺id")
     private Long storeId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("店铺名称")
     private String storeName;
     @ApiModelProperty("定货柜编号")
     private String ctnOrderNum;
     @ApiModelProperty("货柜序货柜序号")
     private String agentCtnNo;

    @ApiModelProperty("国内代理")
    private String chineseAgent;


    @ApiModelProperty("到港时间")
    private Date reachDestinationDate;

    @ApiModelProperty("装柜日期")
    private Date loadTime;
     @ApiModelProperty("清关公司名称")
     private String agentCompany;
     @ApiModelProperty("目的港")
     private String destination;
     @ApiModelProperty("货柜号")
     private String ctnNo;
     @ApiModelProperty("封条号")
     private String sealNo;
     @ApiModelProperty("提单号")
     private String billNo;
     @ApiModelProperty("操作人id")
     private Long operatorId;
     @ApiModelProperty("操作人")
     private String operatorName;
     @ApiModelProperty("排序")
     private Integer sort;
     @ApiModelProperty("备注")
     private String remarks;

    @ApiModelProperty("分单操作请求打包信息ID")
    private Long packId;
    @ApiModelProperty("分单操作请求散货信息ID")
    private Long sackId;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpCtnOrder> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
        }
        if (this.getId() != null){
        lqw.eq(alias+"id" ,this.getId());
        }
        if (this.getPackId() != null){
        lqw.eq(alias+"pack_id" ,this.getPackId());
        }
        if (this.getReceiptId() != null){
            lqw.eq(alias+"receipt_id" ,this.getReceiptId());
        }
        if (this.getCtnArabgeId() != null){
        lqw.eq(alias+"ctn_arabge_id" ,this.getCtnArabgeId());
        }
        if (this.getAgentCompanyId() != null){
        lqw.eq(alias+"agent_company_id" ,this.getAgentCompanyId());
        }
        if (this.getBrandId() != null){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (this.getStoreId() != null){
        lqw.eq(alias+"store_id" ,this.getStoreId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (StringUtils.isNotBlank(this.getStoreName())){
            lqw.like(alias+"store_name",this.getStoreName());
        }
        if (this.getLoadTime() != null){
            lqw.eq(alias+"load_time" ,this.getLoadTime());
        }
        if (this.getChineseAgent() != null){
            lqw.eq(alias+"chinese_agent" ,this.getChineseAgent());
        }
        if (StringUtils.isNotBlank(this.getCtnOrderNum())){
        lqw.eq(alias+"ctn_order_num" ,this.getCtnOrderNum());
        }
        if (StringUtils.isNotBlank(this.getAgentCtnNo())){
        lqw.eq(alias+"agent_ctn_no" ,this.getAgentCtnNo());
        }
        if (StringUtils.isNotBlank(this.getAgentCompany())){
        lqw.eq(alias+"agent_company" ,this.getAgentCompany());
        }
        if (StringUtils.isNotBlank(this.getDestination())){
        lqw.eq(alias+"destination" ,this.getDestination());
        }
        if (StringUtils.isNotBlank(this.getCtnNo())){
        lqw.eq(alias+"ctn_no" ,this.getCtnNo());
        }
        if (StringUtils.isNotBlank(this.getSealNo())){
        lqw.eq(alias+"seal_no" ,this.getSealNo());
        }
        if (StringUtils.isNotBlank(this.getBillNo())){
        lqw.eq(alias+"bill_no" ,this.getBillNo());
        }
        if (this.getOperatorId() != null){
        lqw.eq(alias+"operator_id" ,this.getOperatorId());
        }
        if (StringUtils.isNotBlank(this.getOperatorName())){
            lqw.like(alias+"operator_name",this.getOperatorName());
        }
        if (this.getSort() != null){
        lqw.eq(alias+"sort" ,this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())){
        lqw.eq(alias+"remarks" ,this.getRemarks());
        }
        if (this.getReachDestinationDate() != null){
            lqw.apply("DATE_FORMAT(gcrp.reach_destination_date, '%Y-%m-%d') = '" + DateUtils.dateTime(this.getReachDestinationDate()) + "'");
        }
    }
}
